import requests
import json

def get_access_token():

   url = "https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=urf17rTqw3L4Xtq5PQtb3fR6&client_secret=u6WyT9Omh0zOXYx4q85H7sCl8CZ7XGjU"

   payload = json.dumps("")
   headers = {
      'Content-Type': 'application/json',
      'Accept': 'application/json'
   }
   response = requests.request("POST", url, headers=headers, data=payload)
   return response.json().get("access_token")

def getMsg():
   url = "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions_pro?access_token=" + get_access_token()


   payload = json.dumps({
      "messages": [
         {
               "role": "user",
               "content": "boost库中的to_lower_copy"
         }
      ]
   })
   headers = {
      'Content-Type': 'application/json'
   }

   response = requests.request("POST", url, headers=headers, data=payload)

   print(response.text)


if __name__ == '__main__':
   getMsg()
